<template>
  <div class="ycdwrap">
    <div class="yc-table-wrp">
      <div>
        <yc-title class="title" value="流通码详情"></yc-title>
      </div>
     <div class="acc-man-body">
        <div><label>流通码:</label><span v-if="product_code">{{product_code}}</span> <span v-else>无</span></div>
        <div><label>对应箱码:</label><span v-if="box_code">{{box_code}}</span><span v-else>无</span></div>
        <div><label>商品名称:</label><span v-if="good_name">{{good_name}}</span><span v-else>无</span></div>
      </div>
      <yc-table ref ="codeTabe" :total="total" :cdTableData="tableInfo"></yc-table>
    </div>
  </div>
</template>

<script>
import request from 'request'
import ycTable from './com/table'
import ycButton from '@/components/button.vue'
import ycTitle from '@/components/ycTitle.vue'
export default {
  name: 'codeDetail',
  components: {
    ycTable,
    ycTitle,
    ycButton
  },
  data () {
    return {
      box_code: '',
      product_code: '',
      good_name: '',
      endDate: '',
      tableInfo: [],
      total: null,
      row: ''
    }
  },
  methods: {
    init (val) {
      if (this.row.productCode) {
        request.getProductDetailList1(this.row.productCode).then(res => {
          this.product_code = res.product_code
          this.box_code = res.box_code
          this.good_name = res.good_name
        })
      }
      if (this.row.productCode) {
        var params = {
          p: val || 1,
          size: 10
        }
        request.getProductDetailList(this.row.productCode, {
          params
        }).then(res => {
          this.tableInfo = res.records
          this.total = res.total
        })
      }
    }
  },
  created () {
    if (this.$route.params.row) {
      this.row = this.$route.params.row
    } else {
      let data = localStorage.getItem('CodetempData')
      this.row = JSON.parse(data).row
    }
  }
}
</script>

<style lang="stylus" scoped="scoped">
.yc-table-wrp{
  .acc-man-body{
    margin  0 0 40px 0
    padding 10px 0 0 0
    >div{
      margin 10px 0 0 0
      >label{
        margin 0 10px 0 0
      }
    }
  }
  .newadd{
    float right
    margin 20px 0
  }
}
</style>
